let mongoose = require('../model/db.js');

//用户表
let userSchema = new mongoose.Schema({
  name: String, //app名字
  recommendation_code: String, //推荐吗
  imgsrc: String, //图片路径
  tell: Number, //电话号码
  vip_grade: Number, //vip等级
  real_name: String, //真实姓名
  sex: Boolean, ///性别
  age: Number, //年龄
  address: Array, //地址
  ipnum: String, //身份证
  password: String, //密码
  register_time: Date, //注册时间
  pay_password: String, //支付密码
  my_follow: Array, //我的关注
  my_collection: Array, //我的收藏
  my_look: Array, //我的浏览
  wx_bind: String, //微信绑定
  tell_bind: String, //手机号绑定
  my_gladpage: Array, //我的黄金叶
  my_coupon: Array, //我的优惠券,
  my_buyed: Array, //已购买的商品 购买历史
  my_firiend: Array, //我的好友
  my_jifen: Number,
});
// 后台人员表
let background_userSchema = new mongoose.Schema({
  user: String, //用户名
  password: String, //密码
  bind_contact: String, //绑定手机号
  authentic_name: String, //认证姓名
  identity_name: String, //身份名称
  avatar:String,
  identity_id: {
    type: mongoose.Types.ObjectId,
    ref: 'identity',
  },
});
// 后台人员身份表
let identitySchema = new mongoose.Schema({
  identity_name: String, //身份
  identity_describe: String, //身份描述
  Permissions_id: {
    type: [mongoose.Types.ObjectId],
    ref: 'Permissions',
  },
});
// 后台人员权限表
let PermissionsSchema = new mongoose.Schema({
  permissions_name: String, //权限名称
  permissions_url: String, //权限路径
  permissions_level: Number, //权限类型
  pid: {
    type: mongoose.Types.ObjectId,
    ref: 'Permissions',
  },
});
// 活动表
let Publish_an_eventSchema = new mongoose.Schema({
  activity_name: String,//活动名称
  activity_type: String,//活动类型
  activity_Begin_time: String,//活动开始时间
  activity_end_time: String,//活动结束时间 
  Activity_Definition: Array,//活动定义
  Activity_Level_Restrictions: Array,//等级限制
  Activity_Resources: String,//资源
  activity_describe: String,//活动描述
  activity_img: String,//活动图片
  Active_istrue: Boolean,//活动是否开启
  active_jiangpin: Object,//活动奖品
})

//订单
let OrderSchema = new mongoose.Schema({
  parment: String,//订单状态
  imgs: String,//图片
  names: String,//商品名
  introduce: String,//介绍
  wgt: Number,//重量
  prince: Number,//价格
  username: String,//客户名
  num: Number,//数量
  withdraw:Boolean,//是否退货
  address: String,//地址
  invoce: String,//发票
  tel: String,//电话
  data: String,//日期
  coupon: Number,//优惠券
  integral: Number,//金叶子 折扣
  deliver: String,//配送方式自提还是配送
  problem: String,//问题
})

// 商品表
let commoditySchema = new mongoose.Schema({
  commodity_guige: String,//商品规格
  commodity_price: Number,//商品价格
  commodity_jifen: Number,//商品积分
  commodity_pinpai: String,//商品品牌
  commodity_name: String,//商品名称
  commodity_xingzhi: String,//商品性质
  commodity_diqu: String,//商品地区
  commodity_time: Date,//商品时间
  commodity_canshu: Object,//商品参数
  commodity_xinxi: String,//商品信息
  commodity_img1: String,//商品图片
  commodity_img2: String,//商品图片
  commodity_img3: String,//商品图片
  commodity_img4: String,//商品图片
  commodity_type: String,//商品类型
  price_shuoming: String,//价格说明
  commodity_number: Number,//商品数量
  commodity_istrue: Boolean,//商品是否可以使用积分换购
})
// 参与活动人员表
let participate_activitySchema = new mongoose.Schema({
  name:String,//参与活动人员名称
  phone:String,//参与活动用户手机号
  time:Date,//参与活动时间
  activity_name:String,//参与活动名称
  activity_jiangpin:String,//参与活动获得奖品
  activity_jiangpin_istrue:Boolean,//参与活动奖品是否领取
  activity_jiangpin_time:Date,//参与活动奖品领取到期时间
  activity_image:String,//参与活动奖品图片
})




let Video = new mongoose.Schema({
  name: String,
  videoSrc: String,
  context: String,
});


let backgrounduserModel = mongoose.model('background_user', background_userSchema, 'background_user')
let identityModel = mongoose.model('identity', identitySchema, 'identity')
let PermissionsModel = mongoose.model('Permissions', PermissionsSchema, 'Permissions')
let Publish_an_eventModel = mongoose.model('Publish_an_event', Publish_an_eventSchema, 'Publish_an_event')
let commodityModel = mongoose.model('commodity', commoditySchema, 'commodity')
let UsersModel = mongoose.model('user', userSchema, 'user')
let videoMOdel = mongoose.model('Video', Video, 'Video');
let OrderModel = mongoose.model('Order', OrderSchema, 'Order');
let participate_activityModel = mongoose.model('participate_activity', participate_activitySchema, 'participate_activity');
module.exports = {
  backgrounduserModel,//后台人员表
  identityModel, //后台人员身份表
  PermissionsModel, //后台权限表
  Publish_an_eventModel, //活动表
  commodityModel,//商品表
  participate_activityModel,//参与活动人员表
  UsersModel,
  videoMOdel,
  OrderModel,//订单
};
